主题
Base64编码 - Base64Encode
函数简介
对数据进行Base64编码。
接口名称
Base64EncodeDLL调用
c
long Base64Encode(long instance, string source);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| source | 字符串 | 要进行Base64编码的源数据。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
string encoded = ola.Base64Encode("hello ola");csharp
using OLAPlug;
var ola = new OLAPlugServer();
string encoded = ola.Base64Encode("hello ola");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
encoded = ola.Base64Encode("hello ola")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
String encoded = ola.Base64Encode("hello ola");cpp
var ola = com("OlaPlug.OlaSoft")
var encoded = ola.Base64Encode("hello ola")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
encoded = ola.Base64Encode("hello ola")text
.局部变量 ola, OLAPlug
ola.创建 ()
encoded = ola.Base64Encode("hello ola")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var encoded = ola.Base64Encode("hello ola");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
文本型 encoded = ola.Base64Encode("hello ola")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
std::string encoded = ola.Base64Encode("hello ola");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long ptr = Base64Encode(instance, "hello ola");
if (ptr != 0) {
char buffer[4096] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long Base64Encode(long ola, string source);
long instance = CreateCOLAPlugInterFace();
long ptr = Base64Encode(instance, "hello ola");
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string encoded = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ptr = ola.Base64Encode(instance, b"hello ola")返回值
| 返回值 | 说明 |
|---|---|
非 0 | 成功,返回 Base64编码后的字符串指针。 |
0 | 失败。 |
